CON

  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000


var

  byte  array[100]
  
pub go | i, total, t, dt

  waitcnt(cnt + clkfreq<<2)

  dira[0]~~
  outa[0]~

  repeat 4
    !outa[0]

  outa[0]~
  
  repeat i from 0 to 99
    array[i] := i

  t := cnt
  dt := clkfreq / 100
    
  repeat 100
  
    outa[0]~~
    repeat i from 0 to 99
      total += array[i]
     
    total /= 100
     
    repeat 50
      i := (i//5 + total) * 7 
     
    outa[0]~
    t += dt
    waitcnt(t)
     
  repeat
    
  